import React from 'react';
import BodyChild from './bodychild'

export default class BodyIndex extends React.Component {
    constructor() {
        super(); //调用基类的所有的初始化方法
        this.state = {
            username: 'Parry',
            age: 20
        }
    }

    changeUserInfo(age) {
        this.setState({age: age})
    }

    handleChildValueChange(event) {
        this.setState({
            age: event.target.value
        })
    }

    render() {
        return (
            <div>
                <h3>这里是内容区.</h3>
                <p>{this.props.userid} {this.props.username}</p>
                <p>{this.state.age}</p>
                <input type="button" value='提交' onClick={this.changeUserInfo.bind(this,100)}/>
                <BodyChild age={this.state.age} handleChildValueChange={this.handleChildValueChange.bind(this)}/>
            </div>
        )
    }
}